/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bols;

import entity.Product2;
import facade.Product2FacadeRemote;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author lab1
 */
public class BOL2 {

    Product2FacadeRemote product2Facade = lookupProduct2FacadeRemote();
    //lay ra tach ca Product
    public List<Product2> showAllProduct() {
        return product2Facade.findAll();

    }

    private Product2FacadeRemote lookupProduct2FacadeRemote() {
        try {
            Context c = new InitialContext();
            return (Product2FacadeRemote) c.lookup("java:global/SHOPPINGCART2/SHOPPINGCART2-ejb/Product2Facade!facade.Product2FacadeRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
